package com.ruoyi.web.controller.mobile;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.mobile.domain.HuaweiHealthStat;
import com.ruoyi.mobile.service.IHuaweiHealthStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 华为健康统计数据Controller
 * 
 * @author ruoyi
 * @date 2022-09-23
 */
@RestController
@RequestMapping("/mobile/stat")
public class HuaweiHealthStatController extends BaseController
{
    @Autowired
    private IHuaweiHealthStatService huaweiHealthStatService;

    /**
     * 查询华为健康统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:stat:list')")
    @GetMapping("/list")
    public TableDataInfo list(HuaweiHealthStat huaweiHealthStat)
    {
        startPage();
        List<HuaweiHealthStat> list = huaweiHealthStatService.selectHuaweiHealthStatList(huaweiHealthStat);
        return getDataTable(list);
    }

    /**
     * 导出华为健康统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:stat:export')")
    @Log(title = "华为健康统计数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HuaweiHealthStat huaweiHealthStat)
    {
        List<HuaweiHealthStat> list = huaweiHealthStatService.selectHuaweiHealthStatList(huaweiHealthStat);
        ExcelUtil<HuaweiHealthStat> util = new ExcelUtil<HuaweiHealthStat>(HuaweiHealthStat.class);
        util.exportExcel(response, list, "华为健康统计数据数据");
    }

    /**
     * 获取华为健康统计数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('mobile:stat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(huaweiHealthStatService.selectHuaweiHealthStatById(id));
    }

    /**
     * 新增华为健康统计数据
     */
    @PreAuthorize("@ss.hasPermi('mobile:stat:add')")
    @Log(title = "华为健康统计数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HuaweiHealthStat huaweiHealthStat)
    {
        return toAjax(huaweiHealthStatService.insertHuaweiHealthStat(huaweiHealthStat));
    }

    /**
     * 修改华为健康统计数据
     */
    @PreAuthorize("@ss.hasPermi('mobile:stat:edit')")
    @Log(title = "华为健康统计数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HuaweiHealthStat huaweiHealthStat)
    {
        return toAjax(huaweiHealthStatService.updateHuaweiHealthStat(huaweiHealthStat));
    }

    /**
     * 删除华为健康统计数据
     */
    @PreAuthorize("@ss.hasPermi('mobile:stat:remove')")
    @Log(title = "华为健康统计数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(huaweiHealthStatService.deleteHuaweiHealthStatByIds(ids));
    }
}
